/**
 * 复制文件 不使用 fs.copyFile
 */

const fs = require("fs");
const path = require('path')
const filename = path.resolve(__dirname, './img/xyz.jpg')
const writeFilename = path.resolve(__dirname, './img/xyz.copy.jpg')
/**
 * copyFile 复制文件
 *
 * @param {*} readPath 文件读取路径
 * @param {*} writePath 写入路径
 */
async function copyFile(readPath, writePath) {
    const buffer = await fs.promises.readFile(readPath)
    await fs.promises.writeFile(writePath, buffer)
    console.log('\x1B[42m%s\x1B[49m', 'copyFile success')
}

copyFile(filename, writeFilename)